package com.qt.socket;

import java.io.IOException;
import java.net.*;

/**
 * @Author zsf
 * @Date 2023/10/5 1:17
 * @Version 1.0
 */
public class SendMessageDemo {

    public static void main(String[] args) throws IOException {

        DatagramSocket ds = new DatagramSocket();
        String str = "hello it‘s me";
        byte[] data = str.getBytes();
        InetAddress inetAddress = InetAddress.getByName("127.0.0.1");
        int port = 8888;
        DatagramPacket dp = new DatagramPacket(data, data.length, inetAddress, port);
        ds.send(dp);
        ds.close();


    }


}
